var $axios = axios.create({
    baseURL:'http://localhost:3000/'
});

var footer=[
    {
        name:'首页',
        icon:'icon-shouye',
        url:'../index/index.html'
    },
    {
        name:'职位',
        icon:'icon-position',
        url:'../position/position.html'
    },
    {
        name:'企业',
        icon:' icon-ic_business_enterprise24px',
        url:'../enterprise/enterprise.html'
    },
    {
        name:'消息',
        icon:'icon-xiaoxi',
        url:'../message/message.html'
    },
    {
        name:'我的',
        icon:'icon-wode',
        url:'../my/my.html'
    }
]
var common = {
    formateDate(time) {
        var date = new Date(time);
        var Y = date.getFullYear();
        var M = date.getMonth() + 1;
        var D = date.getDate();

        M = M < 10 ? '0' + M : M;
        D = D < 10 ? '0' + D : D;
        return `${Y}年${M}月${D}日`
    },

    // 获取url后面的参数
    getId() {
        var href = location.href;
        var index = href.indexOf('=');
        var id = href.slice(index + 1);
        return id;
    },

    logout() {
        $('#logout').on('click', function () {
            localStorage.username = '';
            location.href = '../index.html';
        })
    },

    // 若已经登录, 显示用户名
    showUsername() {
        var username = localStorage.username;
        if (username) {
            $('.logined').show().siblings().hide();
            username = decodeURIComponent(username);
            $('#username').text(username);
        } else {
            $('.logined').hide().siblings().show();
        }

    },
    renderFooter(num){
        var footStr = '';
        footer.forEach(function(item,index){
            footStr += `
            <a href="${item.url}" class="index flex fdc aic ${index===num?'active':''}">
        <i class="iconfont ${item.icon}"></i><span class="f14">${item.name}</span>
      </a>
            `;
        })
        $('footer').html(footStr);
    }

}